package com.hps.activemq.mapper;

import com.hps.activemq.entity.Good;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2019-01-11
 */
@Repository
public interface GoodMapper extends BaseMapper<Good> {
    /**
     * 更新库存
     * @param goodId 商品Id
     * @return
     */
    @Update("update t_good set stock = stock - 1 where id = #{goodId} and stock > 0")
    int updateStock(Long goodId);
}
